<template>
<div>
<div><span style="text-align: left;">服务单详情</span><el-button type="warning" @click="$router.push({path:'/tuikuai'})">返回</el-button></div>
<div>
<p style="text-align: left;">服务单信息</p>
<el-form  v-model="Form" label-width="80px" >
  <el-form-item label="服务单号">
    <el-input v-model="Form.id" disabled></el-input>
  </el-form-item>
  <el-form-item label="申请状态">
    <el-input v-if="Form.status==0" value="申请" disabled></el-input>
    <el-input v-if="Form.status==1" value="同意" disabled></el-input>
    <el-input v-if="Form.status==2" value="驳回" disabled></el-input>
  </el-form-item>
  <el-form-item label="订单编号">
    <el-input v-model="Form.orderId" disabled></el-input>
  </el-form-item>
  <el-form-item label="申请时间">
 <el-input v-model="this.youWant" disabled></el-input>
  </el-form-item>
  <el-form-item label="用户账号">
<el-input v-model="Form.userAccount" disabled></el-input>
  </el-form-item>
  <el-form-item label="定金金额">
<el-input v-model="Form.returnMoney" disabled></el-input>
  </el-form-item>
  <el-form-item label="退款金额">
<el-input v-model="Form.returnMoney" disabled></el-input>
  </el-form-item>
  <el-form-item label="退款原因">
<el-input v-model="Form.returnCause" disabled></el-input>
  </el-form-item>
  <el-form-item label="处理备注">
<el-input v-model="Form.remark"></el-input>
  </el-form-item>
  <el-form-item>
      <el-button
       size="mini"
       @click="handleEdit(Form.id, Form.returnMoney);$router.push({path:'/tuikuai'})" v-if="Form.status==0">确定退款</el-button>
      <el-button
      size="mini"
      type="danger"
       @click="handleDelete(Form.id, Form.remark)" v-if="Form.status==0">拒绝退款</el-button>
  </el-form-item>
</el-form>
</div>
</div>
</template>
<script>
export default {
  data () {
    return {
      // 呈现数据
      searchMap: {},
      Form: {},
      id: 0,
      youWant: 0
    }
  },
  methods: {
    async getList () {
      // 发送请求查询数据并返回
      const { data: res2 } = await this.$http.post('/orders/return/order/findList2', this.searchMap)
      this.Form = res2.data[0]
      console.log(res2)
      var d = new Date(res2.data[0].applyTime)
      const youWant = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()
      this.youWant = youWant
    },
    async handleEdit (id, money) {
      await this.$http.get(`/orders/return/order/agreeRefund?id=${id}&&money=${money}`)
      this.getList()
    },
    async handleDelete (id, remark) {
      await this.$http.get(`/orders/return/order/rejectRefund?id=${id}&&remark=${remark}`)
      this.getList()
    }
  },
  // 钩子函数
  async created () {
    this.id = this.$route.query.id
    this.searchMap = { id: this.$route.query.id }
    this.getList()
  }

}
</script>

<style>
</style>
